<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
  <th:block th:include="include :: header('部门列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
  <div class="row">
    <div class="btn-group-sm" id="toolbar" role="group">
      <a class="btn btn-success" onclick="$.operate.addTab(1)" >
        <i class="fa fa-plus"></i> 新增
      </a>
      <a class="btn btn-info" id="expandAllBtn">
        <i class="fa fa-exchange"></i> 展开/折叠
      </a>
    </div>

    <div class="col-sm-12 select-table table-striped">
      <table id="bootstrap-table"></table>
    </div>
  </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">

  var prefix = "/TbGoods"

  // var prefix1 = "/TbProduct"
  $(function() {
    var options = {
      uniqueId: "goodsId",
      search:false,
      url:prefix +"/getGoodsVoList",
      createUrl:prefix+"/add/{id}",
      updateUrl:prefix+"/edit/{id}",
      removeUrl:prefix+"/remove/{id}",
      modalName:"商品",
      pageSize:14,
      pageList:[14,20,40],
      striped:true,
      columns: [
        {
          field: 'goodsName',
          // align:'center',
          title: '商品名称'
        },
        {
          field: 'categoryName',
          align:'center',
          title: '所属分类'

        },
        {
          field: 'inventory',
          align:'center',
          title: '库存'

        },{
          field: 'costPrice',
          align:'center',
          title: '进价'

        },{
          field: 'sellPrice',
          align:'center',
          title: '售价'
        },
        {
          field: 'status',
          align:'center',
          title: '是否上架',

          formatter: function(value, row, index) {
            if (row.status == "1") {
              return '<span class="badge badge-primary">是</span>';
            } else if (row.status == "0") {
              return '<span class="badge badge-danger">否</span>';
            }
          }
        },

        {
          title: '操作',
          align:'center',
          formatter: function(value, row, index) {
            //if (row.parentId != 0) {
              var actions = [];
              actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.goodsId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
              actions.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)" onclick="$.operate.remove(\'' + row.goodsId + '\')"><i class="fa fa-trash"></i>删除</a>');
              return actions.join('');
          }
        }]
    };
    $.table.init(options);
  });
</script>
</body>
</html>